package bean;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

import com.oreilly.servlet.MultipartRequest;

public class SemiDTO {
	private JoinVo vo;
	private Connection conn;

	public SemiDTO() {
		conn = new MyOracle().getConn();
	}
	public boolean login() {
		boolean b = false;
		try {
			String sql="select mid, pwd from semi where mid=? and pwd=?";
			PreparedStatement pst = conn.prepareStatement(sql);
			pst.setString(1, vo.getMid());
			pst.setString(2, vo.getPwd());
			
			ResultSet rs = pst.executeQuery();
			if(rs.next()) b =true;
			
			pst.close();
			conn.close();
			
		} catch (Exception e) {
			e.printStackTrace();
		}
		return b;
	}
	public boolean insert() {
		boolean b = false;
		String sql = "insert into semi(mid,pwd,irum,gender,birth,email,phone,que,job)values(?,?,?,?,?,?,?,?,?)";
		try {
			PreparedStatement pst = conn.prepareStatement(sql);
			pst.setString(1, vo.getMid());
			pst.setString(2, vo.getPwd());
			pst.setString(3,vo.getIrum());
			pst.setString(4,vo.getGender());
			pst.setString(5,vo.getBirth());
			pst.setString(6, vo.getEmail());
			pst.setString(7,vo.getPhone());
			pst.setString(8,vo.getQue());
			pst.setString(9,vo.getJob());

			int cnt = pst.executeUpdate();
			if (cnt > 0)
				b = true;

			pst.close();
			conn.close();
		} catch (Exception ex) {
			ex.printStackTrace();
		}

		return b;

	}
	public boolean delete(){
		boolean b=false;
		
		String sql = "delete from semi where mid=?";
		
		try{
			PreparedStatement pst = conn.prepareStatement(sql);
			pst.setString(1, vo.getMid());
			int cnt = pst.executeUpdate();
			if(cnt>0)b=true;
			
			pst.close();
			conn.close();
		}catch(Exception ex){
			ex.printStackTrace();
		}
		
		return b;
		
		
	}

	public JoinVo getVo() {
		return vo;
	}

	public void setVo(JoinVo vo) {
		this.vo = vo;

	}
	
}
